//
//  CurriculumModel.m
//  GC_OC
//
//  Created by  Quan He on 2022/4/9.
//

#import "CurriculumModel.h"

@implementation NewHomeSectionModel
- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    if ([key isEqualToString:@"content"]) {
        self.content = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            CurriculumModel *model = [[CurriculumModel alloc] initWithDic:dic];
            [self.content addObject:model];
        }
        self.originData = [NSMutableArray array];
        [self.originData addObjectsFromArray:value];
        return;
    }
    if ([key isEqualToString:@"tile"]) {
        self.title = [NSString stringWithFormat:@"%@",value];
        return;
    }
    if ([value isNullObject]) {
        [super setValue:@"" forKey:key];
        return;
    }
    [super setValue:[NSString stringWithFormat:@"%@",value] forKey:key];
}

- (void)setNilValueForKey:(NSString *)key {
    [super setValue:@"" forKey:key];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}
@end

@implementation CurriculumModel
+ (BOOL)propertyIsOptional:(NSString*)propertyName {
    return YES;
}
- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        self.audio_num = @"";
        self.describe = @"";
        self.image = @"";
        self.name = @"";
        self.pid = @"";
        self.pid_name = @"";
        self.media_class = @"";
        self.lable_ids = @"";
        self.media_class_id = @"";
        self.video_num = @"";
        
        self.label = [NSMutableArray array];
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    if ([key isEqualToString:@"describe"]) {
        if (value == nil || [value isNullObject]) {
            [super setValue:@"" forKey:key];
            return;
        }
    }
    [super setValue:[NSString stringWithFormat:@"%@",value] forKey:key];
}

- (void)setNilValueForKey:(NSString *)key {
    [super setValue:@"" forKey:key];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (NSDictionary *)dictionary {
    NSDictionary *dic = @{@"audio_num": self.audio_num,
                          @"id" : self.id,
                          @"describe" : self.describe,
                          @"image" : self.image,
                          @"label" : self.label,
                          @"lable_ids" : self.lable_ids,
                          @"name" : self.name,
                          @"video_num" : self.video_num };
    return dic;
}
@end



